﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="InvokeMethodExpressionToken.cs" company="JDML Consulting Ltd.">
//   Copyright 2011 Photon Project - http://photon.codeplex.com
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Photon.Windows.Input
{
    internal class InvokeMethodExpressionToken
    {
        public static readonly InvokeMethodExpressionToken Dot = new InvokeMethodExpressionToken(".", 
            InvokeMethodExpressionTokenType.Dot);

        public static readonly InvokeMethodExpressionToken Comma = new InvokeMethodExpressionToken(",", 
            InvokeMethodExpressionTokenType.Comma);

        public static readonly InvokeMethodExpressionToken OpenBracket = new InvokeMethodExpressionToken("(", 
            InvokeMethodExpressionTokenType.OpenBracket);

        public static readonly InvokeMethodExpressionToken CloseBracket = new InvokeMethodExpressionToken(")", 
            InvokeMethodExpressionTokenType.CloseBracket);

        public static readonly InvokeMethodExpressionToken QuestionMark = new InvokeMethodExpressionToken("?", 
            InvokeMethodExpressionTokenType.QuestionMark);

        public static readonly InvokeMethodExpressionToken LessThan = new InvokeMethodExpressionToken("<", 
            InvokeMethodExpressionTokenType.LessThan);

        public static readonly InvokeMethodExpressionToken GreaterThan = new InvokeMethodExpressionToken(">", 
            InvokeMethodExpressionTokenType.GreaterThan);

        public static readonly InvokeMethodExpressionToken Star = new InvokeMethodExpressionToken("*", 
            InvokeMethodExpressionTokenType.Star);

        public static readonly InvokeMethodExpressionToken OpenCurlyBrace = new InvokeMethodExpressionToken("{", 
            InvokeMethodExpressionTokenType.OpenCurlyBrace);

        public static readonly InvokeMethodExpressionToken CloseCurlyBrace = new InvokeMethodExpressionToken("}", 
            InvokeMethodExpressionTokenType.CloseCurlyBrace);

        public InvokeMethodExpressionToken(string text, InvokeMethodExpressionTokenType type)
        {
            Text = text;
            Type = type;
        }

        public string Text { get; private set; }

        public InvokeMethodExpressionTokenType Type { get; set; }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(this, obj))
            {
                return true;
            }

            var typedObj = obj as InvokeMethodExpressionToken;
            if (ReferenceEquals(typedObj, null))
            {
                return false;
            }

            return this.Type == typedObj.Type && this.Text == typedObj.Text;
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return ((this.Text != null ? this.Text.GetHashCode() : 0) * 397) ^ this.Type.GetHashCode();
            }
        }
    }
}